package com.handydata.antifraud.rule.funcs;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.handydata.antifraud.to.RiskInputTO;
import com.handydata.antifraud.to.RiskMiddleTO;

/**
 * 计算年龄
 */
@Component
public class CalcXYDPI extends CalculateAdapter {
    private static final Logger logger = LoggerFactory.getLogger(CalcXYDPI.class);
    /**
     * 计算年龄
     * @param riskInputTO
     * @return
     */
    public void doCalc(RiskInputTO riskInputTO, RiskMiddleTO riskMiddleTO) {
        logger.info("{}开始计分辨率{}", RULE_CALC_TEXT,riskInputTO.getScreenResolution());

        String str = riskInputTO.getScreenResolution();
        if (str.length() >0) {
            str=str.replace(" ","");
            String[] strs=str.split("x");
            if(strs.length==2){
                riskMiddleTO.setXdpi(Double.valueOf(strs[0]));
                riskMiddleTO.setYdpi(Double.valueOf(strs[1]));
            }else{
                logger.info("{}分辨率格式不对", str);
            }
        } else  {
            logger.info("{}分辨率格式不对", str);
        }
        logger.info("{}结束分辨率 x{} y{}", RULE_CALC_TEXT,riskMiddleTO.getXdpi(),riskMiddleTO.getYdpi());
    }
}
